class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {

        int left  =0;
        int right = nums.size()-1;
        vector<int> ret;
        while(left<right)
        {
            if(nums[left]+nums[right]>target)
            {
                right--;
            }
            else if(nums[left]+nums[right]<target)
            {
                left++;
            }
            else
            {
                ret.push_back(nums[left]);
                ret.push_back(nums[right]);
                break;
            }
        }
        return ret;
    }
};